//
// Created by wenyaxi on 24-10-29.
//
#include <common.h>
class Solution {
public:
    int maxProfit(vector<int>& prices) {
        int pre_min = prices[0];
        int max_profit = 0;
        for(int i=0;i<prices.size();i++) {
            if(prices[i] < pre_min) {
                pre_min = prices[i];
            }else {
                max_profit = max(max_profit, prices[i] - pre_min);
            }
        }
        return max_profit;
    }
};